package com.xqls.server.dto.send;

import com.xqls.server.dto.SoketCommonDto;
import com.xqls.server.netty.DecoderUtil;

import io.netty.buffer.ByteBuf;
import org.apache.log4j.Logger;

/**
 * 浓度触发采样模式
 * @author Administrator
 *
 */
public class ConcentrationSamplingSetDto extends SoketCommonDto{
    private static Logger logger = Logger.getLogger(SoketCommonDto.class);

    //是否发送过
    private boolean  sendReady=false;
	
	 /**
     * 浓度触发采样模式
     */
    public static  final  String MODEL_CONCENTRATION="0006";
    
    /**
     * 周期采样模式
     */
    private  String periodicMode;
    
    /**
     * 0x00 0x00 不采样;
     * 0x00 0x01 代表采样,每次采样为固定量;
     * 0x00 0x02 每次采样为按比例采样
     * 
     */
    private Integer sampling;
    
    /**
     * 0x00 0x09
     */
    private  Integer Unknown;
    
    /**
     * 超标采样频次
     */
    private Integer exceedStandard;
    
    /**
     * 0x00 0x00
     */
    private Integer Unknown1;
    
    /**
     * 氨氮触发值(百位;千位)
     * (浓度触发采样模式下生效)
     */
    private Integer ht_NH3_N;
    /**
     * PH触发值(该参数*100下发)
     * (浓度触发采样模式下生效)
     */
    private Double PH;
    /**
     * 氨氮触发值(个位;十位)
     * (浓度触发采样模式下生效)
     */
    
    private Integer bt_NH3_N;
   
    /**
     * SS触发值
     * (浓度触发采样模式下生效)
     */
    private Integer SS;
    /**
     * 温度
     */
    private Integer temperature;
    
    /**
     * UV(COD)触发值(该参数*10下发)
     * (浓度触发采样模式下生效)
     */
    private Integer UV;
    
    /**
     * 水量
     */
    private Integer water;
    
    /**
     * 周期
     * 采样周期（当采样模式设置为0x00，0x01）单位分钟
     * 触发周期（当采样模式设置为0x00，0x04）单位分钟
     * 采样模式设置为其他值，本4字节无效
     */
    private Integer  cycle;

    /**
     * 大周期
     * 采样大周期，设定一个大循环采样的时间，单位h
     */
    private Integer bigCycle;
    
    /**
     * 延时启动小时数，设置0x08，0x08，0x08，0x08表示立即启动，设置<8888，表示延时设置的若干小时后再启动
     */
    private  Integer  delayedStar;

	public String getPeriodicMode() {
		return periodicMode;
	}

	public void setPeriodicMode(String periodicMode) {
		this.periodicMode = periodicMode;
	}
	
	
	public Integer getSampling() {
		return sampling;
	}

	public void setSampling(Integer sampling) {
		this.sampling = sampling;
	}
	
	

	public Integer getUnknown1() {
		return Unknown1;
	}

	public void setUnknown1(Integer unknown1) {
		Unknown1 = unknown1;
	}

	public Integer getUnknown() {
		return Unknown;
	}

	public void setUnknown(Integer unknown) {
		Unknown = unknown;
	}
	

	public Integer getExceedStandard() {
		return exceedStandard;
	}

	public void setExceedStandard(Integer exceedStandard) {
		this.exceedStandard = exceedStandard;
	}

	public Integer getHt_NH3_N() {
		return ht_NH3_N;
	}

	public void setHt_NH3_N(Integer ht_NH3_N) {
		this.ht_NH3_N = ht_NH3_N;
	}

	public Integer getBt_NH3_N() {
		return bt_NH3_N;
	}

	public void setBt_NH3_N(Integer bt_NH3_N) {
		this.bt_NH3_N = bt_NH3_N;
	}

	public Double getPH() {
		return PH;
	}

	public void setPH(Double pH) {
		PH = pH;
	}

	public Integer getSS() {
		return SS;
	}

	public void setSS(Integer sS) {
		SS = sS;
	}
	

	public Integer getTemperature() {
		return temperature;
	}

	public void setTemperature(Integer temperature) {
		this.temperature = temperature;
	}

	public Integer getUV() {
		return UV;
	}

	public void setUV(Integer uV) {
		UV = uV;
	}

	public Integer getWater() {
		return water;
	}

	public void setWater(Integer water) {
		this.water = water;
	}

	public Integer getCycle() {
		return cycle;
	}

	public void setCycle(Integer cycle) {
		this.cycle = cycle;
	}

	public Integer getBigCycle() {
		return bigCycle;
	}

	public void setBigCycle(Integer bigCycle) {
		this.bigCycle = bigCycle;
	}

	public Integer getDelayedStar() {
		return delayedStar;
	}

	public void setDelayedStar(Integer delayedStar) {
		this.delayedStar = delayedStar;
	}

	public Integer getLength(){
		return 26;
	}
	public String getCode() {
		return "ca";
	}


	public void encode( ByteBuf byteBuf){

        if(!sendReady){
            
            DecoderUtil.integerToBytes(this.getUnknown(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getHt_NH3_N(),byteBuf,2);
			Double phDouble=this.getPH()*100;
            DecoderUtil.integerToBytes(phDouble.intValue(),byteBuf,4);
            DecoderUtil.integerToBytes(this.getSS()*10,byteBuf,4);
            DecoderUtil.integerToBytes(this.getTemperature()*100,byteBuf,4);
            DecoderUtil.integerToBytes(this.getBt_NH3_N(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getUV()*10,byteBuf,4);
            super.encode(byteBuf);
            sendReady=true;
        }else{
            byteBuf.writeBytes(DecoderUtil.hexStringToBytes(this.getPeriodicMode()));
            DecoderUtil.integerToBytes(this.getSampling(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getUnknown1(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getExceedStandard(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getWater(),byteBuf,4);
            DecoderUtil.integerToBytes(this.getCycle(),byteBuf,4);
            DecoderUtil.integerToBytes(this.getBigCycle(),byteBuf,2);
            DecoderUtil.integerToBytes(this.getDelayedStar(),byteBuf,4);
            super.encode(byteBuf);
        }
    }

}
